from django.contrib.auth.models import AbstractUser
from django.db import models
# Create your models here.

class Clazz(models.Model):
    class_name = models.CharField(max_length=50, unique=True,
                            verbose_name='课程名字',db_comment="课程名字")
    teacher_name=models.CharField(max_length=20,verbose_name='班主任')
    duration=models.IntegerField(db_comment="课程时间")
    status=models.BooleanField(db_comment="状态 0 毕业 1 正常",null=True,blank=True,default=True)
    create_time = models.DateTimeField(auto_now_add=True,db_comment="录入时间",null=True,blank=True)
    updata_time = models.DateTimeField(auto_now=True, db_comment="修改时间", null=True, blank=True)
    delete = models.BooleanField(db_comment="删除标记",db_default=False,blank=True,db_column="is_delete")
    class Meta:
        db_table = 'tb_clazz'

class User(AbstractUser):
    class_id=models.ForeignKey(to=Clazz, on_delete=models.RESTRICT
                ,blank=True,null=True,db_column="class_id",related_name='users')
    # 用户表中的每个学生关联 班级表的id
    name=models.CharField(max_length=10, verbose_name='真实姓名',db_comment="真实姓名")
    tel=models.CharField(max_length=11)
    status = models.BooleanField(db_comment="状态 0 普通用户 1 企业用户", null=True, blank=True, default=False)
    create_time = models.DateTimeField(auto_now_add=True, db_comment="录入时间", null=True, blank=True)
    updata_time = models.DateTimeField(auto_now=True, db_comment="修改时间", null=True, blank=True)
    delete = models.BooleanField(db_comment="删除标记", db_default=False, blank=True,db_column="is_delete")

    class Meta:
        swappable = 'AUTH_USER_MODEL'
        db_table = 'auth_user'

# class Staff(models.Model):
#     group_name=models.CharField(max_length=30, verbose_name='组名',db_comment="组名")
#     status = models.BooleanField(db_comment="状态 0 普通用户 1 企业用户", null=True, blank=True, default=False)
#     create_time = models.DateTimeField(auto_now_add=True, db_comment="录入时间", null=True, blank=True)
#     updata_time = models.DateTimeField(auto_now=True, db_comment="修改时间", null=True, blank=True)
#     is_delete = models.BooleanField(db_comment="删除标记", db_default=False, blank=True)
#     # 人员组表 绑定用户表id
#     staff_id = models.ManyToManyField(to=User, on_delete=models.RESTRICT,
#                     db_comment="任务id",blank=True,null=True,related_name="staffs")
#     # 人员组表 绑定班级表id
#     class_id = models.ManyToManyField(to=Clazz, on_delete=models.RESTRICT,
#                         db_comment="人员组id", blank=True, null=True, related_name="users")
# class Stage(models.Model):
#     stage_name=models.CharField(max_length=10, verbose_name='阶段名',db_comment="阶段名")
#     create_time = models.DateTimeField(auto_now_add=True, db_comment="录入时间", null=True, blank=True)
#     updata_time = models.DateTimeField(auto_now=True, db_comment="修改时间", null=True, blank=True)
#     is_delete = models.BooleanField(db_comment="删除标记", db_default=False, blank=True)
#
# class Modular(models.Model):
#     modular_name=models.CharField(max_length=10, verbose_name='模块名',db_comment="模块名")
#     create_time = models.DateTimeField(auto_now_add=True, db_comment="录入时间", null=True, blank=True)
#     updata_time = models.DateTimeField(auto_now=True, db_comment="修改时间", null=True, blank=True)
#     is_delete = models.BooleanField(db_comment="删除标记", db_default=False, blank=True)
#     stage_id=models.ForeignKey(to=Stage,on_delete=models.RESTRICT
#                 ,blank=True,null=True,related_name='modulars')
# class Task(models.Model):
#     stage_name = models.CharField(max_length=10, verbose_name='阶段名', db_comment="阶段名")
#     modular_name = models.CharField(max_length=10, verbose_name='模块名', db_comment="模块名")
#     task_title = models.CharField(max_length=30, verbose_name='任务标题', db_comment="任务标题")
#     degree= models.CharField(max_length=5, db_comment="难易程度")
#     task_id = models.ForeignKey(to=User, on_delete=models.RESTRICT,
#                         db_comment="任务id", blank=True, null=True, related_name="tasks")
#
# class Allot(models.Model):
#     task_status=models.IntegerField(db_comment="任务状态", null=True, blank=True)
#     task_answer=models.CharField(max_length=300,db_comment="任务答案", null=True, blank=True)
#     check_time = models.DateTimeField(auto_now=False, db_comment="检查时间", null=True, blank=True)
#     create_time = models.DateTimeField(auto_now_add=True, db_comment="录入时间", null=True, blank=True)
#     updata_time = models.DateTimeField(auto_now=True, db_comment="修改时间", null=True, blank=True)
#     allot_time=models.DateTimeField(auto_now=True, db_comment="分配时间", null=True, blank=True)
#     task_id = models.ForeignKey(to=Task, on_delete=models.RESTRICT,
#                         db_comment="任务id", blank=True, null=True, related_name="allots")
#     user_id=models.ForeignKey(to=User, on_delete=models.RESTRICT,
#                         db_comment="任务id", blank=True, null=True, related_name="allots")